home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group95c.txt
/
000083_icon-group-sender _Sun Nov 12 20:23:40 1995.msg
< prev
next >
Wrap
Internet Message Format
|
1996-01-03
|
1KB
Received: by cheltenham.cs.arizona.edu; Wed, 22 Nov 1995 10:43:36 MST
To: icon-group@cs.arizona.edu
Date: 12 Nov 1995 20:23:40 GMT
From: john@nmt.edu (John Shipman)
Message-Id: <485l4c$erl@newshost.nmt.edu>
Organization: New Mexico Tech Computer Center
Sender: icon-group-request@cs.arizona.edu
Subject: Comparing sets for equality
Errors-To: icon-group-errors@cs.arizona.edu
I need an Icon function to test two sets to see if they're identical.
Is there an operator that does this, that I have somehow missed?
If not, here's how I implemented it. I reasoned that if the two
sets are the same size, and their set difference is zero, then they
must be identical. Questions:
1. Is my reasoning correct?
2. Is this more or less the fastest way to do this?
3. Is there anything wrong with my implementation (below)?
----------------------------------------------------------------
#-[ If x and y are sets with identical elements ->
# returns y
# | else if x and y are sets with non-identical elements ->
# fails
#-]
procedure Set_Equal ( x, y )
if ( ( * x ) = ( * y ) ) & # If element counts are the same...
( ( * ( x -- y ) ) = 0 ) then # ...and set difference is empty
return y
else
fail;
end
John Shipman, js@cs.nmt.edu, http://www.nmt.edu/~john
Zoological Data Processing, 507 Fitch NW, Socorro, NM 87801 USA